package org.orange.feign.simulate.openfeign.service;


import org.orange.feign.simulate.openfeign.core.anno.CustomFeignClient;
import org.orange.feign.simulate.feign.common.pojo.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@CustomFeignClient(url = "http://127.0.0.1:8080", fallback = TestFeignClient.Fallback.class)
@RequestMapping(value = "/user")
public interface UserFeignClient {

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    User getUserById(@PathVariable("id") int id);

    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
    User getUserInfo(@PathVariable("id") int id);

    class Fallback implements UserFeignClient {

        @Override
        public User getUserById(int id) {
            return new User(id, "getPaymentById熔断降级方法返回");
        }

        @Override
        public User getUserInfo(int id) {
            return new User(id, "getPaymentInfo熔断降级方法返回");
        }
    }
}
